import {Store, Getter, Mutation, Action} from 'decorators/vuex'

@Store
export class TopicStore {
  bgImg = ''
  topicTitle = ''
  topicDec = ''
  isinDate = ''

  product = {
    title: '',
    dec: '',
    images: [],
    productId: [],
    cover: ''
  }

  @Getter
  isinDate(state) {
    return state.isinDate
  }

  @Getter
  topicTitle(state) {
    return state.topicTitle
  }

  @Getter
  topicDec(state) {
    return state.topicDec
  }

  @Getter
  html(state) {
    return state.html
  }

  @Mutation
  isinDate(state, string) {
      state.isinDate = string
  }

  @Mutation
  topicTitle(state, data) {
    state.topicTitle = data
  }

  @Mutation
  topicDec(state, string) {
    state.topicDec = string
  }

  @Mutation
  saveHtml(state, string) {
    state.html = string
  }

  @Mutation
  bgImg(state, url) {
    state.bgImg = url
  }

  @Mutation
  clearData(state) {
    state.topicTitle = ''
    state.topicDec = ''
    state.bgImg = ''
    console.log(state.bgImg)
    state.isinDate = ''
  }

  @Action
  editImagesModel ({commit}, data) {
    commit('saveImages', data)
  }

  @Action
  editCover ({commit}, data) {
    commit('bgImg', data)
  }
}
